package com.stylefeng.guns.modular.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.UserCwMapper;
import com.stylefeng.guns.modular.system.model.UserCw;
import com.stylefeng.guns.modular.system.service.IUserCwService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统用户表 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2018-08-24
 */
@Service
@CacheConfig(cacheNames ="local")
public class UserCwServiceImpl extends ServiceImpl<UserCwMapper, UserCw> implements IUserCwService {

    /**
     * 设置用户的角色
     *
     * @param userId
     * @param roleIds
     */
    @Override
    @CachePut(key = "'userCw_'+#userId")
    public int setRoles(Integer userId, String roleIds) {
        return this.baseMapper.setRoles(userId, roleIds);
    }

    @Override
    @CacheEvict(allEntries = true,beforeInvocation=true)
    public int setStatus(Integer userId, int status) {
        return this.baseMapper.setStatus(userId, status);
    }
}
